<?php
include_once('../../app/connection.php');

if(isset($_POST['action']))
{
    $action = $_POST['action'];
    $value = $_POST['value'];
    if($action == "khoa")
    {
?>
    <table>
        <tr style="background: #247CB9;">
            <td style="width: 100px; text-align: center; color: #fff;">Mã GV</td>
            <td style="width: 200px; text-align: center; color: #fff;">Họ tên</td>
            <td style="width: 100px; text-align: center; color: #fff;">Năm sinh</td>
            <td style="width: 50px; text-align: center; color: #fff;">Giới tính</td>
            <td style="width: 50px; text-align: center; color: #fff;">Khoa</td>
        </tr>
        
    <?php
        if($value == 'ALL')
            $sql = mysql_query("SELECT * FROM giaovien WHERE TRANGTHAI = 1");
        else if($value == '')
                $sql = mysql_query("SELECT * FROM giaovien WHERE MAKHOA ='' AND TRANGTHAI = 1");
            else
                $sql = mysql_query("SELECT * FROM giaovien WHERE MAKHOA = '". $value . "' AND TRANGTHAI = 1");
            
            
        if(mysql_num_rows($sql) == 0)
            echo 'Khoa '. $value .' không tồn tại';
        else
            while($rows = mysql_fetch_assoc($sql))
            {
    ?>
             <tr>
             <td style="text-align: center;"><div class="chon_ms" onclick="xemthongtin('<?php echo $rows['MAGIAOVIEN']; ?>')">
                    <?php echo $rows['MAGIAOVIEN']; ?></div></td>
             <td><?php echo $rows['HOTEN']; ?></td>
             <td style="text-align: center;"><?php echo $rows['NGAYSINH']; ?></td>
             <td style="text-align: center;"><?php echo ($rows['GIOITINH'] == 0)?'Nam':'Nữ'; ?></td>
             <td><?php echo $rows['MAKHOA'] ?></td>
             </tr>
    <?php } ?>
    
    </table>
    
<?php 
    }
} 
?>